import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("merchant", { schema: "charge" })
export class Merchant {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("int", { name: "parent_id", default: () => "'0'" })
  parentId: number;

  @Column("varchar", { name: "name", comment: "商户名称", length: 20 })
  name: string;

  @Column("varchar", { name: "tel", comment: "电话", length: 20 })
  tel: string;

  @Column("int", {
    name: "admin_id",
    comment: "管理员id",
    unsigned: true,
    default: () => "'0'",
  })
  adminId: number;

  @Column("decimal", {
    name: "profit_rate",
    comment: "分润比例",
    precision: 3,
    scale: 2,
    default: () => "'0.00'",
  })
  profitRate: string;

  @Column("varchar", { name: "payee", comment: "收款人", length: 10 })
  payee: string;

  @Column("varchar", { name: "account", comment: "收款账号", length: 20 })
  account: string;

  @Column("varchar", { name: "bank", comment: "银行", length: 20 })
  bank: string;

  @Column("decimal", {
    name: "amount",
    comment: "可提现金额",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  amount: string;

  @Column("decimal", {
    name: "withdrawal_amount",
    comment: "已提现",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  withdrawalAmount: string;

  @Column("decimal", {
    name: "frozen_amount",
    comment: "冻结",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  frozenAmount: string;

  @Column("int", {
    name: "total_charge_order_count",
    comment: "总充电订单数",
    unsigned: true,
    default: () => "'0'",
  })
  totalChargeOrderCount: number;

  @Column("decimal", {
    name: "total_charge_amount",
    comment: "总收入",
    precision: 12,
    scale: 2,
    default: () => "'0.00'",
  })
  totalChargeAmount: string;

  @Column("float", {
    name: "total_charge_kwh",
    unsigned: true,
    precision: 15,
    scale: 5,
    default: () => "'0.00000'",
  })
  totalChargeKwh: number;

  @Column("int", {
    name: "total_charge_time",
    comment: "总充电时长，秒",
    unsigned: true,
    default: () => "'0'",
  })
  totalChargeTime: number;

  @Column("boolean", { name: "enable"})
  enable: boolean;

  @Column("int", {
    name: "creator_id",
    comment: "创建人",
    unsigned: true,
    default: () => "'0'",
  })
  creatorId: number;

  @Column("int", { name: "create_time", default: () => "'0'" })
  createTime: number;

  @Column("int", { name: "update_time", default: () => "'0'" })
  updateTime: number;
}
